Before we begin our exercise, we need to install all the needed
packages - we only need to use install.packages() once for
each. However EVERY time you start using R you will need to run
library() to load the installed package.
In this exercise we are going to leverage the package
osmdata to directly query and download features from OSM.
This package will directly access the Overpass Turbo
API to create and make queries directly from the R environment.
Nevertheless, the use of the overpass-turbo.eu can be useful when we are
not sure what we are looking for or when we have some difficulty in
building the query.
See here for some basics on OverpassTurbo and a formal guide on queries.
In order to structure all the data in the world, OSM created a
hierarchical data structure. In this case we can think of the world
being broken down into spatial features (e.g. points, lines, polygons)
each with a tag made up of a Key (e.g. amenity, building,
highway etc) and Value (e.g. coffee shop, primary
road).
We can look the tagging convension on OSM’s map features directory.
We can list all the the available OSM features using
available_features() to list the available feature
keys. In this case - to limit the length of the output we will
use head() so we only view the first 5 features listed.
# list top five
head(available_features())
## [1] "4wd_only" "abandoned" "abutters" "access" "addr" "addr:city"
# list all
# available_features()
Now we can see what the different types of buildings are based on
their tag value. Here again we are using
head() so that we only see the first five results.
# list first 5 building types
head(available_tags("building"))
## [1] "apartments" "bakehouse" "barn" "barracks" "beach_hut"
## [6] "bridge"
# list all building types
# available_tags("building")
Use the available_features() and
available_tags("a_feature_name") to find the feature and
tag name for stores that sell
alcohol.
# enter your answer here
In this example we will be exploring the area around you in Jamaica. First it helps to go to OSM and figure how features and tags can be found.
To find feature tag pairs zoom to a business of interest, right-click > Show Address > click on link to results > top row is [feature, tag] in this case [amenity, bank].